CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
PROJECT(eds_tof_sdk)

set(TARGET_NAME eds_tof_sdk)

SET(CMAKE_CXX_STANDARD "17")
SET(CMAKE_C_STANDARD "17")


set(PCL "FALSE")


include_directories("src/prot_tcp")
# add file dir
list( APPEND LIST_DIR  "src")
list( APPEND LIST_DIR  "src/prot_tcp")


foreach( dir  ${LIST_DIR} )
    message( STATUS ${dir})
    FILE( GLOB  SRC_LIST "${PROJECT_SOURCE_DIR}/${dir}/*.cpp")
    list(APPEND ALL_SRC_LIST ${SRC_LIST})
    include_directories(AFTER ${dir})
endforeach()


if( "${TYPE}" STREQUAL "TEST")
    add_definitions(-DTEST)
elseif("${TYPE}" STREQUAL "DEBUG")
    add_definitions(-DDEBUG)
    SET(CMAKE_BUILD_TYPE "Debug")   
else()    
    SET(CMAKE_BUILD_TYPE "Release")
endif()


if( "${TYPE}" STREQUAL "TEST")
    add_executable( ${TARGET_NAME} ${ALL_SRC_LIST})
else()
    list(REMOVE_ITEM ALL_SRC_LIST "${PROJECT_SOURCE_DIR}/src/main.cpp")
    add_library( ${TARGET_NAME}  SHARED ${ALL_SRC_LIST} )
endif()
target_link_libraries(${TARGET_NAME} pthread  ) 

if("${PCL}" STREQUAL "TRUE")
    find_package(PCL 1.2 REQUIRED COMPONENTS common io)
    include_directories(${PCL_INCLUDE_DIRS})
    link_directories(${PCL_LIBRARY_DIRS})
    add_definitions(${PCL_DEFINITIONS})
    target_link_libraries(${TARGET_NAME} ${PCL_LIBRARIES})
    add_definitions(-DPCL)
endif()


# version info
string( TIMESTAMP  COMPILE_TIME "%Y-%m-%d %H:%M:%S " )
add_definitions(-DCOMPILE_TIME="${COMPILE_TIME}")
add_definitions(-DVER="1.1")
site_name(host)
add_definitions(-DHOST="${host}")


set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")

SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g2 -ggdb ")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall ")

